<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let persons = [
            {
                username: '张飞',
                sex: '男',
                salary: 50000
            },
            {
                username: '关羽',
                sex: '男',
                salary: 60000
            }
        ]
        // 声明一个空数组用来存储新的值
        let arr = [];
        for(let i = 0; i < persons.length; i++){
            // 声明一个空对象来拷贝persons中元素的值
            let t = {};
            Object.assign(t,persons[i]);
            // 给拷贝对象中的salary值加2000
            t.salary += 2000;
            // 给空数组添加t
            arr.push(t);
        }
        console.log(arr,persons);
    </script>
</body>

</html>